import { createApp } from "vue";
import "./style.css";
import "./assets/css/base.scss";
import "vant/es/notify/style";
import App from "./App.vue";
import router from "./router/index";
import { initRem } from "./utils/rem";
import { createPinia } from "pinia";
import { useUserStore } from "./store/user";
initRem(); //初始化rem配置
declare module "@vue/runtime-core" {
  interface ComponentCustomProperties {
    $myLog: () => void; //自定义全局属性的类型声明
  }
}
const pinia = createPinia();

const app = createApp(App);
app.use(pinia); //注入pinia状态机
//从本存储提取用户信息，给到状态机
const user = useUserStore();
let uinfo = localStorage.getItem("userInfo");
if (uinfo) {
  user.userInfo = JSON.parse(uinfo);
}
app.use(router); //路由注入
app.config.globalProperties.$myLog = () => {
  //挂载全局属性
  console.log("一个自定义的全局方法");
};
app.mount("#app");
